package logic

import (
	"context"
	"shop-ease/model"

	"shop-ease/shoprpc/internal/svc"
	"shop-ease/shoprpc/shoprpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type QuesListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewQuesListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QuesListLogic {
	return &QuesListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *QuesListLogic) QuesList(in *shoprpc.QuesListRequest) (*shoprpc.QuesListResponse, error) {
	// todo: add your logic here and delete this line

	var ques []model.Questions
	model.DB.Debug().Find(&ques)
	var quesList []*shoprpc.QuesList
	for _, que := range ques {

		list := shoprpc.QuesList{
			UserId: int64(que.UserId),
			Issue:  que.Issue,
		}
		quesList = append(quesList, &list)
	}
	return &shoprpc.QuesListResponse{
		List: quesList,
	}, nil
}
